package sk.octopuss.archery.web;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import sk.octopuss.archery.domain.User;
import sk.octopuss.archery.service.UserService;

@Controller
public class LoginController extends AbstractController {
	
			@Autowired
			UserService userService;

			@RequestMapping(value="/registerOpenId", method=RequestMethod.GET)
			public String registrationOpenId(final HttpServletRequest request) {
			  final String userId = (String) request.getSession().getAttribute("USER_OPENID_CREDENTIAL");
			  if(userId != null) {
				final User user = new User();  
				user.setOpenID(userId);
			    user.setPassword("unused");
			    user.setActive(true);
			    //setMessage(request, "Your account has been created. Please log in using your OpenID.");
			     return "redirect:login";
			  } else {
			    //setMessage(request, "Please register using your OpenID.");
			    return "redirect:register";
			  }
			}
}
